package com.xiaoke.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoke.domain.ResponseResult;
import com.xiaoke.domain.entity.Category;
import com.xiaoke.domain.vo.GetCategoryListVo;
import com.xiaoke.mapper.CategoryMapper;
import com.xiaoke.service.CategoryService;
import com.xiaoke.utils.BeanCopyUtils;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.xiaoke.constants.SystemConstants.STATUS_NORMAL;

/**
 * 文章分类表(Category)表服务实现类
 *
 * @author xiaoke
 * @since 2023-03-17 10:25:48
 */
@Service("categoryService")
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {

    @Override
    public ResponseResult getCategoryList() {
        LambdaQueryWrapper<Category> queryWrapper = new LambdaQueryWrapper<>();

        queryWrapper
                .eq(Category::getStatus,STATUS_NORMAL);

        List<Category> categoryList = list(queryWrapper);

        List<GetCategoryListVo> getCategoryListVos = BeanCopyUtils.copyBeanList(categoryList, GetCategoryListVo.class);

        return ResponseResult.okResult(getCategoryListVos);

    }
}

